/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.una.pol.ii.is2.domain.sistema;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "rol")
@NamedQueries({@NamedQuery(name = "Rol.findAll", query = "SELECT r FROM Rol r"), @NamedQuery(name = "Rol.findByRolCod", query = "SELECT r FROM Rol r WHERE r.rolCod = :rolCod"), @NamedQuery(name = "Rol.findByRolNombre", query = "SELECT r FROM Rol r WHERE r.rolNombre = :rolNombre"), @NamedQuery(name = "Rol.findByRolDescripcion", query = "SELECT r FROM Rol r WHERE r.rolDescripcion = :rolDescripcion")})
public class Rol implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="rol_generator")
    @SequenceGenerator(allocationSize=1, name="rol_generator", sequenceName="rol_rol_cod_seq")
    @Basic(optional = false)
    @Column(name = "rol_cod")
    private Integer rolCod;
    @Basic(optional = false)
    @Column(name = "rol_nombre")
    private String rolNombre;
    @Basic(optional = false)
    @Column(name = "rol_descripcion")
    private String rolDescripcion;
    @ManyToMany(mappedBy = "rolCollection", cascade=CascadeType.ALL)
    private Collection<Usuario> usuarioCollection;
    @OneToMany(cascade = CascadeType.MERGE, mappedBy = "rol")
    private Collection<PantRol> pantRolCollection;

    public Rol() {
    }

    public Rol(Integer rolCod) {
        this.rolCod = rolCod;
    }

    public Rol(Integer rolCod, String rolNombre, String rolDescripcion) {
        this.rolCod = rolCod;
        this.rolNombre = rolNombre;
        this.rolDescripcion = rolDescripcion;
    }

    public Integer getRolCod() {
        return rolCod;
    }

    public void setRolCod(Integer rolCod) {
        this.rolCod = rolCod;
    }

    public String getRolNombre() {
        return rolNombre;
    }

    public void setRolNombre(String rolNombre) {
        this.rolNombre = rolNombre;
    }

    public String getRolDescripcion() {
        return rolDescripcion;
    }

    public void setRolDescripcion(String rolDescripcion) {
        this.rolDescripcion = rolDescripcion;
    }

    public Collection<Usuario> getUsuarioCollection() {
        return usuarioCollection;
    }

    public void setUsuarioCollection(Collection<Usuario> usuarioCollection) {
        this.usuarioCollection = usuarioCollection;
    }

    public Collection<PantRol> getPantRolCollection() {
        return pantRolCollection;
    }

    public void setPantRolCollection(Collection<PantRol> pantRolCollection) {
        this.pantRolCollection = pantRolCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rolCod != null ? rolCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rol)) {
            return false;
        }
        Rol other = (Rol) object;
        if ((this.rolCod == null && other.rolCod != null) || (this.rolCod != null && !this.rolCod.equals(other.rolCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.ii.is2.dao.flota.Rol[rolCod=" + rolCod + "]";
    }

}
